var url = "ws://swoole.kinggui.com:8811";
var ws = new WebSocket(url);
//
ws.onopen = function (evt) {
    console.log('connected live success!');
}
ws.onmessage = function (evt) {
    console.log("live-server-return:" + evt.data);
    push(evt.data);
}
ws.onclose = function (evt) {
    console.log('live disconnnected!');
}
ws.onerror = function (evt) {
    console.log('live occur a wrong');
}

function push(data){
    data = JSON.parse(data);
    html = '<div class="frame">';
    html += '<h3 class="frame-header">';
    html += '<i class="icon iconfont icon-shijian"></i>第' + data.type + '节 03：30';
    html += '</h3>';
    html += '<div class="frame-item">';
    html += '<span class="frame-dot"></span>';
    html += '<div class="frame-item-author">';
    if(data.logo){
        html += '<img src="' + data.logo + '" width="20px" height="20px" />' + data.title;
    }
    html += '</div>';
    html += '<p>' + data.content + '</p>';
    if(data.image){
        html += '<p><img src="' + data.image + '" width="40%" /></p>';
    }
    html += '</div>';
    html += '</div>';

    $('#match-result').prepend(html);
}